package top.soulblack.purchasesale.mapper;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Mapper;
import top.soulblack.purchasesale.model.StoreHouse;

import java.util.List;

/**
 * @Author: 韦溜溜
 * @Description:仓库管理mppaer
 * @Date: Create in 13:20 2019/5/19
 */
@Mapper
public interface StoreHouseMapper{

    Integer updateById(StoreHouse storeHouse);

    Integer insert(StoreHouse storeHouse);

    @Results(id = "storeHouse",value ={
            @Result(column = "id",property = "storeId"),
            @Result(column = "name",property = "storeName"),
            @Result(column = "status",property = "storeStatus"),
            @Result(column = "remarks",property = "remarks"),
            @Result(column = "sort",property = "sort"),
            @Result(column = "user_id",property = "userId"),
            @Result(column = "shop_id",property = "shopId"),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "update_time",property = "updateTime")
    })
    @Select("select *from store_house")
    List<StoreHouse> selectList();

    @ResultMap("storeHouse")
    @Select("SELECT * FROM store_house WHERE id = #{id}")
    StoreHouse selectById(@Param("id") Integer storeId);

    @Delete("DELETE FROM store_house WHERE id = #{id}")
    Integer deleteById(@Param("id") Integer storeId);

    @ResultMap("storeHouse")
    @Select("SELECT *FROM  store_house where  store_house.shop_id= #{shopId}")
    List<StoreHouse> selectByShopId(@Param("shopId") Integer shopId);


}
